/**
 * File：   blog请求api.
 */
import {post} from './post'
// 获取博客用户信息
function getBlogMemberInfo(memberId) {
  return post('/index.php?act=member_fans&op=get_member_info', {member_id: memberId})
}
// 获取心情日志类型列表
function getDiaryClassify() {
  return post('index.php?act=member_exp&op=getType', {type: 'moodlog'})
}
// 发布心情日志
function addDiary(classifyId, content, imgList) {
  return post('/index.php?act=member_exp&op=member_new_diary', {d_ids: classifyId, content: content, images: imgList})
}
// 删除心情日志
function delDiary(id) {
  return post('/index.php?act=member_exp&op=member_del_diary', {id: id})
}
// 更新心情日志
function updateDiary(id, content, imgList) {
  return post('/index.php?act=member_exp&op=member_edit_diary', {id: id, content: content, images: imgList})
}
// 获取用户的心情日志列表 如果memberId为空，则查询当前登录用户的心情日志列表
function getMemberDiaryList(page, pageSize, memberId) {
  return post('/index.php?act=member_exp&op=member_list_diary', {page: page, pageSize: pageSize, member_id: memberId})
}
// 获取心情日志列表, index_page: 是否为系统推荐 0非 1是
function getDiaryList(page, pageSize, index_page) {
  return post('/index.php?act=index&op=memberDiaryList', {index_page: index_page, page: page, pageSize: pageSize})
}
// 获取文章类型列表
function getArticleClassify() {
  return post('index.php?act=member_exp&op=getType', {type: 'article'})
}
// 添加文章
function addArticle(classifyId, title, content) {
  return post('/index.php?act=member_exp&op=member_new_exp', {d_ids: classifyId, title: title, content: content})
}
// 删除文章
function delArticle(id) {
  return post('/index.php?act=member_exp&op=member_del_exp', {id: id})
}
// 更新文章
function updateArticle(id, classifyId, title, content) {
  return post('/index.php?act=member_exp&op=member_save_exp', {id: id, d_ids: classifyId, title: title, content: content})
}
// 获取文章详情
function getArticleInfo(id) {
  return post('/index.php?act=blog_a&op=memberExpDetail', {id: id})
}
// 获取用户的文章列表 如果memberId为空，则查询当前登录用户的文章列表
function getMemberArticleList(page, pageSize, memberId) {
  return post('/index.php?act=member_exp&op=member_list_exp', {page: page, pageSize: pageSize, member_id: memberId})
}
// 获取精品文章列表,articleType：0普通文章 1精品文章， index_page: 是否为系统推荐 0 非 1是
function getArticleList(page, pageSize, articleType, keyword, index_page) {
  return post('/index.php?act=index&op=memberExpList', {
    keyword: keyword,
    index_page: index_page,
    page: page,
    pageSize: pageSize,
    type: articleType
  })
}
// 修改文章点赞状态 0 为取消点赞, 1为点赞
function setArticleThumb(id, status) {
  return post('/index.php?act=member_fans&op=update_exp_thumb', {exp_id: id, state: status})
}
// 获取百科里的推荐的用户文章
function getArticleListByMid(mid, page, pageSize) {
  return post('/index.php?act=flower_baike&op=get_member_exp_list', {m_id: mid, page: page, pageSize: pageSize})
}
// 获取商品相关的用户文章（通过商品关联的植物百科关键字匹配)
function getRelationArticleList(mid, page, pageSize) {
  return post('/index.php?act=index&op=get_keys_exp', {m_id: mid, page: page, pageSize: pageSize})
}
// 获取商品相关的用户心情日记（通过商品关联的植物百科关键字匹配）
function getRelationDiaryList(mid, page, pageSize) {
  return post('/index.php?act=index&op=get_keys_diary', {m_id: mid, page: page, pageSize: pageSize})
}
// 关注
function addFollow(memberId) {
  return post('/index.php?act=member_fans&op=update_follow', {state: '1', member_id: memberId})
}
// 关注
function delFollow(memberId) {
  return post('/index.php?act=member_fans&op=update_follow', {state: '0', member_id: memberId})
}
// 获取用户的关注列表 如果memberId为空，则查询当前登录用户的关注列表
function getFollowList(page, pageSize, memberId) {
  return post('/index.php?act=member_fans&op=get_follow_list', {page: page, pageSize: pageSize, member_id: memberId})
}
// 获取用户的粉丝列表 如果memberId为空，则查询当前登录用户的粉丝列表
function getFansList(page, pageSize, memberId) {
  return post('/index.php?act=member_fans&op=get_fans_list', {page: page, pageSize: pageSize, member_id: memberId})
}
export {
  getBlogMemberInfo,
  getDiaryClassify,
  addDiary,
  delDiary,
  updateDiary,
  getMemberDiaryList,
  getDiaryList,
  getArticleClassify,
  addArticle,
  delArticle,
  getArticleInfo,
  updateArticle,
  getArticleList,
  getMemberArticleList,
  setArticleThumb,
  getArticleListByMid,
  getRelationArticleList,
  getRelationDiaryList,
  addFollow,
  delFollow,
  getFollowList,
  getFansList
}
